﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using BobDotNet.Classes.Base;

namespace BobDotNet.Classes.Dao
{
    class DaoEtatDevis
    {
        public static EtatDevis Charge(string id)
        {
            return DaoEtatDevis.Charge(Int32.Parse(id));
        }

        public static EtatDevis Charge(Int32 id)
        {
            return (EtatDevis)DaoBase.Charge(id, EtatDevis.NomClasse);
        }

        public static List<EtatDevis> ChargeTout()
        {
            List<EtatDevis> retour;
            ISession session = NHibernateSessionManager.Instance.GetSession();
            retour = (List<EtatDevis>)session.CreateCriteria(typeof(EtatDevis)).List<EtatDevis>();
            NHibernateSessionManager.Instance.CloseSession();
            return retour;
        }

        public static void MettreAJour(EtatDevis u)
        {
            try
            {
                DaoBase.MettreAJour(u);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void Creer(EtatDevis u)
        {
            try
            {
                DaoBase.Creer(u);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void Supprimer(string Id)
        {
            DaoEtatDevis.Supprimer(Int32.Parse(Id));
        }

        public static void Supprimer(Int32 Id)
        {
            DaoEtatDevis.Supprimer(DaoEtatDevis.Charge(Id));
        }

        public static void Supprimer(EtatDevis u)
        {
            try
            {
                DaoBase.Supprimer(u);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
